Developer Documentation
PATH  WebObjects 4.0 Documentation > WebObjects Tools and Techniques

Table of Contents Previous Section

Using Direct to Web in Other WebObjects Applications

Other WebObjects applications (that is, applications not using the Direct to Web option in the wizard) can use the Direct to Web framework to display query, list, edit, and other pages in the Direct to Web repetoire. Making use of Direct to Web can be a convenient shortcut for many applications when all they need is a standard database-related page. They can use Direct to Web in one of two ways:

Embedding Direct to Web Components

Using a Direct To Web component is not much different than using any other off-the-shelf component. The procedure is the following.

  1. Add the DirectToWeb framework to your project. You can find this framework in NEXT_ROOT/System/Library/Frameworks.

  2. Decide which Direct to Web component you want to use and become familiar with its API.

    See "Direct to Web Component Reference" for summaries of these components.

  3. Put a WebObjects tag for the component in the page that is to display it.
    <webObject name=MyD2WQuery></webObject>

    This is a step you can complete in WebObjects Builder.

  4. Make the appropriate bindings for the component.
    MyD2WQuery: D2WQuery {
    	entityName="Movie";
    	displayKeys="( title, roles, studio.budget )";
    	queryDataSource=movieDisplayGroup.dataSource;
    }
    

    All embedded components require an entityName binding to specify the entity the page will be dealing with. Extra bindings could be required, depending on the functionality of the page. For example, List pages require a dataSource binding.

    You can also complete this step in WebObjects Builder.

  5. If necessary, implement the action method for the component.

  6. You can customize embedded Direct to Web components using the WebAssistant. But first you must add a file named user.d2wmodel to the Resources category of your application project. The WebAssistant uses this file to maintain your settings. In addition, before you launch the WebAssistant, make sure rapid-turnaround is enabled for your application. You can then launch the WebAssistant using the appletviewer tool; see "Running WebAssistant With appletviewer".
When the WebAssistant acts upon a non-DirectToWeb application, it does not automatically track which page is displayed. Thus you must point it at the page you want to modify in Expert mode. For example, if you want to customize a list page for Movies, you will have to click Expert Mode and then select "list" as the Task and "Movie" as the entity. You can then customize a component in the same way you customize DirectToWeb pages. Also, when you click Update to send the new settings to the application, the browser does not automatically refresh your page. You must either click the "Reload" button in your browser or (especially in cases where you pick a new type of component) you must re-navigate to the page.

Table of Contents Next Section